Commit 547735f8 by Patryk Czarnik

Gotowy projekt WS-Security

parent 213969a0
# Przygotowanie kluczy używanych w przykładzie
# Generowanie kluczy.
# Wykonywać pojedynczo - polecenia są interaktywne
keytool -genkeypair -keystore serwer.jks -storepass abc123 -alias serwer -keyalg RSA
keytool -genkeypair -keystore klient.jks -storepass abc123 -alias klient -keyalg RSA
# Wyeksportowanie certyfikatów (kluczy publicznych)
keytool -export -keystore serwer.jks -storepass abc123 -alias serwer -file serwer.cer
keytool -export -keystore klient.jks -storepass abc123 -alias klient -file klient.cer
# I zaimportowanie ich do keystorów drugiej strony (serwer będzie znał public key klienta i na odwrót)
keytool -import -keystore serwer.jks -storepass abc123 -alias klient -file klient.cer
keytool -import -keystore klient.jks -storepass abc123 -alias serwer -file serwer.cer
# Wersja uproszczona i wbrew zasadom: Skopiowanie całych kluczy z jednego keystore do drugiego.
# W obu będą także klucze prywatne drugiej strony
# keytool -importkeystore -srckeystore serwer.jks -destkeystore klient.jks -srcstorepass abc123 -deststorepass abc123 -srcalias serwer -destalias serwer
# keytool -importkeystore -srckeystore klient.jks -destkeystore serwer.jks -srcstorepass abc123 -deststorepass abc123 -srcalias klient -destalias klient
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.vavatech.szkolenie.secure_soap</groupId>
<artifactId>P41-WSSec-Serwer</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.ws.security</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-api</artifactId>
<version>1.0.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-common</artifactId>
<version>2.1.10</version>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.alx.szkolenie.secure_soap</groupId>
<artifactId>P41-WSSec-Serwer</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifestEntries>
<Dependencies>org.apache.ws.security</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.4</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jboss.ws</groupId>
<artifactId>jbossws-api</artifactId>
<version>1.0.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-common</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</project>
Usługa zabezpieczona za pomocą WS-Security, polityka "encrypt and sign" w oparciu o klucze asymetryczne.
Ta konfiguracja jest właściwa dla serwerów z grupy JBoss, na innych serwerach szczegóły będą się różnić.
Kroki zabezpieczania aplikacji SOAP:
Przygotowania:
* Zwykła aplikacja jak P06-OgloszeniaSoap
* Wygenerowanie (lub w innym scenariuszu ręczne napisanie) WSDL dla tej usługi
i przekonfigurowanie tak, aby klasa z implementacją (SerwisOgloszeniowy) wskazywała istniejący plik WSDL.
Od tej pory serwer nie generuje WSDL automatycznie, tylko używa naszego.
Właściwa konfiguracja WS Security:
* pom.xml - dodatkowe biblioteki oraz wpis w MANIFEST
* src/webapp/WEB-INF/wsdl/SerwisOgloszeniowy.wsdl
- ręcznie dopisana (no dobrze, skopiowana z przykładu...) konfiguracja: reguły polityki (koniec pliku) i odwołanie do niej w binding
* src/webapp/WEB-INF/jaxws-endpoint-config.xml
- ustawienia rozumiane przez JBossWS
* src/main/resources - plik z kluczami oraz propertiesy
* klasa SerwisOgloszeniowy - adnotacje odwołujące się do WSDL i powyższego pliku z konfiguracją JBoss
* klasa PasswordCallback
Polecenia generowania kluczy - patrz plik generowanie_kluczy.txt
Ustawienia klienta:
* klasy wygenerowane poleceniem
wsimport -keep -s src/main/java -d target/classes -p ogloszenia.generated "http://localhost:8080/P41-WSSec-Serwer-1.0/SerwisOgloszeniowyService?wsdl"
* pom.xml - wiele bibliotek
* src/main/resources/META-INF - plik z kluczami oraz propertiesy;
* klasa PasswordCallback
* oraz odpowiedni kod w programach łączących się z serwerem: Klient1 i Klient2.
\ No newline at end of file
package ogloszenia.baza;
import java.sql.Connection;
public abstract class AbstractDAO {
protected DostepDoBazy baza;
protected AbstractDAO(DostepDoBazy baza) {
this.baza = baza;
}
protected Connection c() {
return baza.getC();
}
}
package ogloszenia.baza;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import ogloszenia.exn.BladBazyDanych;
import ogloszenia.util.Ustawienia;
public class DostepDoBazy implements AutoCloseable {
private Connection c;
public DostepDoBazy() throws BladBazyDanych {
Properties props = Ustawienia.wczytaj();
try {
Class.forName(props.getProperty("driver_class"));
c = DriverManager.getConnection(props.getProperty("url") , props);
} catch (ClassNotFoundException | SQLException e) {
throw new BladBazyDanych("Błąd podczas łączenia z bazą", e);
}
}
public void close() {
try {
if(c != null)
c.close();
} catch (Exception e) {
System.err.println("WARNING: Błąd poczas rozłączania");
e.printStackTrace();
}
}
Connection getC() {
return c;
}
public void beginTransaction() throws SQLException {
c.setAutoCommit(false);
c.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
}
public void endTransaction(boolean commit) throws SQLException {
if(commit) {
c.commit();
} else {
c.rollback();
}
c.setAutoCommit(true);
}
public OgloszeniaDAO ogloszeniaDAO() {
return new OgloszeniaDAO(this);
}
public SprzedawcyDAO sprzedawcyDAO() {
return new SprzedawcyDAO(this);
}
}
package ogloszenia.baza;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
public class Konwersje {
public static LocalDateTime timestampToDateTime(Timestamp ts) {
if(ts == null)
return null;
else
return ts.toLocalDateTime();
}
public static Timestamp dateTimeToTimestamp(LocalDateTime d) {
if(d == null)
return null;
else
return Timestamp.valueOf(d);
}
public static LocalDateTime dateTimeOfString(String s) {
if(s == null)
return null;
else
return LocalDateTime.parse(s.replace(' ', 'T'));
}
public static String dateTimeToString(LocalDateTime d) {
if(d == null)
return null;
else
return d.toString();
}
public static LocalDate dateOfString(String s) {
if(s == null)
return null;
else
return LocalDate.parse(s);
}
public static String dateToString(LocalDate d) {
if(d == null)
return null;
else
return d.toString();
}
}
package ogloszenia.baza;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.LinkedList;
import java.util.List;
import ogloszenia.exn.BladBazyDanych;
import ogloszenia.exn.NieznanyRekord;
import ogloszenia.model.Ogloszenie;
import ogloszenia.model.Samochodowe;
import ogloszenia.model.Sprzedawca;
public class OgloszeniaDAO extends AbstractDAO {
OgloszeniaDAO(DostepDoBazy baza) {
super(baza);
}
/** Lista id wszystkich ogłoszeń <strong>samochodowych</strong>.
* @return
* @throws SQLException
*/
public List<Integer> listaIdOgloszen() throws BladBazyDanych {
final String sql = "SELECT id_ogloszenia FROM samochodowe ORDER BY id_ogloszenia";
List<Integer> lista = new LinkedList<>();
try(PreparedStatement stmt = c().prepareStatement(sql)) {
try(ResultSet rs = stmt.executeQuery()) {
while(rs.next()) {
lista.add(rs.getInt(1));
}
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return lista;
}
/** Zwraca listę wszystkich ogłoszeń samochodowych wraz z danymi sprzedawców.
* @return
* @throws BladBazyDanych
*/
public List<Samochodowe> odczytajWszystkie() throws BladBazyDanych {
final String sql = "SELECT * FROM ogloszenia INNER JOIN samochodowe USING(id_ogloszenia) ORDER BY id_ogloszenia";
List<Samochodowe> lista = new LinkedList<>();
try(PreparedStatement stmt = c().prepareStatement(sql)) {
try(ResultSet rs = stmt.executeQuery()) {
wypelnijListeOgloszenDanymiZResultSet(lista, rs);
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return lista;
}
/** Odczytuje jedno ogłoszenie.
* @param idOgloszenia które ma być odczytane
* @return
* @throws BladBazyDanych
* @throws NieznanyRekord gdy nie istnieje rekord o podanym id
*/
public Samochodowe odczytajWgId(int idOgloszenia) throws BladBazyDanych, NieznanyRekord {
final String sql = "SELECT * FROM ogloszenia INNER JOIN samochodowe USING(id_ogloszenia)"
+ " WHERE id_ogloszenia = ?";
try(PreparedStatement stmt = c().prepareStatement(sql)) {
stmt.setInt(1, idOgloszenia);
try(ResultSet rs = stmt.executeQuery()) {
if(rs.next()) {
Samochodowe ogloszenie = ogloszenieZResultSet(rs);
return ogloszenie;
} else {
throw new NieznanyRekord("Brak ogłoszenia o id="+idOgloszenia);
}
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
}
/** Odczytuje ogłoszenia o cenie a podanego przedziału
* @param cenaOd minimalna cena szukanych ogłoszeń, lub null jeśli nie ma dolnej granicy
* @param cenaDo maksymalna cena szukanych ogłoszeń, lub null jeśli nie ma dolnej granicy
* @return
* @throws BladBazyDanych
*/
public List<Samochodowe> odczytajWedlugCeny(BigDecimal cenaOd, BigDecimal cenaDo) throws BladBazyDanych {
//final String sql = "SELECT * FROM ogloszenia WHERE cena BETWEEN ? AND ?";
final String sql = "SELECT * FROM ogloszenia INNER JOIN samochodowe USING(id_ogloszenia)"
+ " WHERE cena BETWEEN ? AND ?"
+ " ORDER BY id_ogloszenia";
if(cenaOd == null)
cenaOd = BigDecimal.ZERO;
if(cenaDo == null)
cenaDo = new BigDecimal(1_000_000_000);
List<Samochodowe> lista = new LinkedList<>();
try(PreparedStatement stmt = c().prepareStatement(sql)) {
stmt.setBigDecimal(1, cenaOd);
stmt.setBigDecimal(2, cenaDo);
try(ResultSet rs = stmt.executeQuery()) {
wypelnijListeOgloszenDanymiZResultSet(lista, rs);
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy w metodzie ogloszeniaWedlugCeny: " + e.getMessage(), e);
}
return lista;
}
/** Zapisuje rekord do bazy danych.
* Jeśli istniał już rekord o podanym id, jest nadpisywany.
* Jeśli rekord posiada id, ale w bazie nie ma rekordu o takim id, jest dodawany.
* Jeśli rekord nie posiada id, nowe id jest generowane z sekwencji, rekord jest dodawany z takim nowym id, a to id jest także ustawiane w obiekcie ogl
* @param ogl ogłoszenie do zapisania; obiekt może zostać zmodyfikowany na dwa sposoby: jeśli nie posiadał id, nowe id jest generowane z sekwencji; jeśli nie posiadał pola wystawione, wpisywany jest bieżący czas
* @throws BladBazyDanych
*/
public void zapisz(Samochodowe ogl) throws BladBazyDanych {
if(ogl.getIdOgloszenia() == null) {
// wstawiamy nowy rekord korzystajac z sekwecji
dodajNowy(ogl);
} else {
if(! aktualizuj(ogl)) {
dodaj(ogl);
}
}
}
public boolean dodajNowy(Samochodowe ogloszenie) throws BladBazyDanych {
// nowe id z sekwencji - podejście z takich baz jak PostgreSQL czy Oracle
final String sql1 = "SELECT nextval('seq_ogloszenia')";
int nextId;
try(PreparedStatement stmt1 = c().prepareStatement(sql1);
ResultSet rs1 = stmt1.executeQuery()) {
if(rs1.next()) {
nextId = rs1.getInt(1);
} else {
throw new BladBazyDanych("nie działa sequence");
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
ogloszenie.setIdOgloszenia(nextId);
if(ogloszenie.getWystawione() == null) {
ogloszenie.setWystawione(LocalDateTime.now());
}
return this.dodaj(ogloszenie);
}
public boolean dodaj(Samochodowe ogl) throws BladBazyDanych {
// dwa inserty, bo dane są podzielone na dwie tabele
final String sql1 = "INSERT INTO ogloszenia("
+ " id_ogloszenia, id_sprzedawcy, wystawione, cena, lokalizacja, tytul, opis)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?)";
final String sql2 = "INSERT INTO samochodowe("
+ " id_ogloszenia, marka, model, generacja, kolor, rocznik, przebieg, pojemnosc, moc)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
try(PreparedStatement stmt = c().prepareStatement(sql1)) {
stmt.setInt(1, ogl.getIdOgloszenia());
stmt.setInt(2, ogl.getIdSprzedawcy());
stmt.setTimestamp(3, Konwersje.dateTimeToTimestamp(ogl.getWystawione()));
stmt.setBigDecimal(4, ogl.getCena());
stmt.setString(5, ogl.getLokalizacja());
stmt.setString(6, ogl.getTytul());
stmt.setString(7, ogl.getOpis());
int ile = stmt.executeUpdate();
if(ile < 1)
return false;
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
try(PreparedStatement stmt = c().prepareStatement(sql2)) {
stmt.setInt(1, ogl.getIdOgloszenia());
stmt.setString(2, ogl.getMarka());
stmt.setString(3, ogl.getModel());
stmt.setString(4, ogl.getGeneracja());
stmt.setString(5, ogl.getKolor());
stmt.setInt(6, ogl.getRocznik());
stmt.setInt(7, ogl.getPrzebieg());
stmt.setFloat(8, ogl.getPojemnosc());
stmt.setFloat(9, ogl.getMoc());
int ile = stmt.executeUpdate();
if(ile < 1)
return false;
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return true;
}
public boolean aktualizuj(Samochodowe ogl) throws BladBazyDanych {
final String sql1 = "UPDATE ogloszenia"
+ " SET id_ogloszenia=?, id_sprzedawcy=?, wystawione=?, cena=?, lokalizacja=?, tytul=?, opis=?"
+ " WHERE id_ogloszenia=?";
final String sql2 = "UPDATE samochodowe"
+ " SET id_ogloszenia=?, marka=?, model=?, generacja=?, kolor=?, rocznik=?, przebieg=?, pojemnosc=?, moc=?"
+ " WHERE id_ogloszenia=?";
try(PreparedStatement stmt = c().prepareStatement(sql1)) {
stmt.setInt(1, ogl.getIdOgloszenia());
stmt.setInt(2, ogl.getIdSprzedawcy());
stmt.setTimestamp(3, Konwersje.dateTimeToTimestamp(ogl.getWystawione()));
stmt.setBigDecimal(4, ogl.getCena());
stmt.setString(5, ogl.getLokalizacja());
stmt.setString(6, ogl.getTytul());
stmt.setString(7, ogl.getOpis());
stmt.setInt(8, ogl.getIdOgloszenia());
int ile = stmt.executeUpdate();
if(ile < 1)
return false;
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
try(PreparedStatement stmt = c().prepareStatement(sql2)) {
stmt.setInt(1, ogl.getIdOgloszenia());
stmt.setString(2, ogl.getMarka());
stmt.setString(3, ogl.getModel());
stmt.setString(4, ogl.getGeneracja());
stmt.setString(5, ogl.getKolor());
stmt.setInt(6, ogl.getRocznik());
stmt.setInt(7, ogl.getPrzebieg());
stmt.setFloat(8, ogl.getPojemnosc());
stmt.setFloat(9, ogl.getMoc());
stmt.setInt(10, ogl.getIdOgloszenia());
int ile = stmt.executeUpdate();
if(ile < 1)
return false;
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return true;
}
private void wypelnijListeOgloszenDanymiZResultSet(List<Samochodowe> lista, ResultSet rs) throws SQLException, BladBazyDanych {
while(rs.next()) {
Samochodowe ogloszenie = ogloszenieZResultSet(rs);
lista.add(ogloszenie);
}
}
private Samochodowe ogloszenieZResultSet(ResultSet rs) throws SQLException, BladBazyDanych {
Samochodowe ogloszenie = new Samochodowe(
rs.getInt("id_ogloszenia"),
rs.getInt("id_sprzedawcy"),
Konwersje.timestampToDateTime(rs.getTimestamp("wystawione")),
rs.getBigDecimal("cena"),
rs.getString("lokalizacja"),
rs.getString("tytul"),
rs.getString("opis"),
rs.getString("marka"),
rs.getString("model"),
rs.getString("generacja"),
rs.getString("kolor"),
rs.getInt("rocznik"),
rs.getInt("przebieg"),
rs.getFloat("pojemnosc"),
rs.getFloat("moc"));
uzupelnijDaneSprzedawcy(ogloszenie);
return ogloszenie;
}
private void uzupelnijDaneSprzedawcy(Ogloszenie ogloszenie) throws BladBazyDanych {
SprzedawcyDAO sdao = baza.sprzedawcyDAO();
Sprzedawca sprzedawca = sdao.odczytajWgId(ogloszenie.getIdSprzedawcy());
ogloszenie.setSprzedawca(sprzedawca);
}
}
package ogloszenia.baza;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import ogloszenia.exn.BladBazyDanych;
import ogloszenia.model.Sprzedawca;
public class SprzedawcyDAO extends AbstractDAO {
protected SprzedawcyDAO(DostepDoBazy baza) {
super(baza);
}
public List<Integer> listaIdSprzedawcow() throws BladBazyDanych {
final String sql = "SELECT id_sprzedawcy FROM sprzedawcy";
List<Integer> lista = new LinkedList<>();
try(PreparedStatement stmt = c().prepareStatement(sql)) {
try(ResultSet rs = stmt.executeQuery()) {
while(rs.next()) {
lista.add(rs.getInt(1));
}
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return lista;
}
public List<Sprzedawca> odczytajWszystkich() throws BladBazyDanych {
final String sql = "SELECT * FROM sprzedawcy";
List<Sprzedawca> lista = new LinkedList<>();
try(PreparedStatement stmt = c().prepareStatement(sql)) {
try(ResultSet rs = stmt.executeQuery()) {
while(rs.next()) {
lista.add(sprzedawcaZResultSet(rs));
}
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
return lista;
}
public Sprzedawca odczytajWgId(int idSprzedawcy) throws BladBazyDanych {
final String sql = "SELECT * FROM sprzedawcy WHERE id_sprzedawcy = ?";
try(PreparedStatement stmt = c().prepareStatement(sql)) {
stmt.setInt(1, idSprzedawcy);
try(ResultSet rs = stmt.executeQuery()) {
if(rs.next()) {
return sprzedawcaZResultSet(rs);
} else {
return null;
}
}
} catch (SQLException e) {
throw new BladBazyDanych("Błąd bazy", e);
}
}
private Sprzedawca sprzedawcaZResultSet(ResultSet rs) throws SQLException {
return new Sprzedawca(rs.getInt("id_sprzedawcy"),
rs.getString("nazwa"),
rs.getString("ulica"),
rs.getString("kod_pocztowy"),
rs.getString("miasto"),
rs.getString("email"),
rs.getString("telefon"));
}
}
package ogloszenia.exn;
public class BladAplikacji extends Exception {
public BladAplikacji() {
super();
}
public BladAplikacji(String message, Throwable cause) {
super(message, cause);
}
public BladAplikacji(String message) {
super(message);
}
public BladAplikacji(Throwable cause) {
super(cause);
}
}
package ogloszenia.exn;
public class BladBazyDanych extends BladAplikacji {
public BladBazyDanych() {
super();
}
public BladBazyDanych(String message, Throwable cause) {
super(message, cause);
}
public BladBazyDanych(String message) {
super(message);
}
public BladBazyDanych(Throwable cause) {
super(cause);
}
}
package ogloszenia.exn;
public class NieznanyRekord extends BladAplikacji {
public NieznanyRekord() {
super();
}
public NieznanyRekord(String message) {
super(message);
}
}
package ogloszenia.model;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="ogloszenia")
public class ListaOgloszen {
@XmlElement(name="ogloszenie")
public List<Samochodowe> ogloszenia;
}
package ogloszenia.model;
import java.time.LocalDateTime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class LocalDatetimeAdapter extends XmlAdapter<String, LocalDateTime> {
@Override
public LocalDateTime unmarshal(String s) {
return LocalDateTime.parse(s);
}
@Override
public String marshal(LocalDateTime d) {
return d.toString();
}
}
package ogloszenia.model;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
public class Ogloszenie {
@XmlAttribute(name="id")
private Integer idOgloszenia;
@XmlAttribute(name="id-sprzedawcy")
private Integer idSprzedawcy;
@XmlJavaTypeAdapter(LocalDatetimeAdapter.class)
private LocalDateTime wystawione;
private BigDecimal cena;
private String lokalizacja;
private String tytul;
private String opis;
private Sprzedawca sprzedawca;
public Ogloszenie() {
}
public Ogloszenie(Integer idOgloszenia, Integer idSprzedawcy, LocalDateTime wystawione, BigDecimal cena, String lokalizacja,
String tytul, String opis) {
super();
this.idOgloszenia = idOgloszenia;
this.idSprzedawcy = idSprzedawcy;
this.wystawione = wystawione;
this.cena = cena;
this.lokalizacja = lokalizacja;
this.tytul = tytul;
this.opis = opis;
}
public Integer getIdOgloszenia() {
return idOgloszenia;
}
public void setIdOgloszenia(Integer idOgloszenia) {
this.idOgloszenia = idOgloszenia;
}
public Integer getIdSprzedawcy() {
return idSprzedawcy;
}
public void setIdSprzedawcy(Integer idSprzedawcy) {
this.idSprzedawcy = idSprzedawcy;
}
public Sprzedawca getSprzedawca() {
return sprzedawca;
}
public void setSprzedawca(Sprzedawca sprzedawca) {
this.sprzedawca = sprzedawca;
}
public LocalDateTime getWystawione() {
return wystawione;
}
public void setWystawione(LocalDateTime wystawione) {
this.wystawione = wystawione;
}
public BigDecimal getCena() {
return cena;
}
public void setCena(BigDecimal cena) {
this.cena = cena;
}
public String getLokalizacja() {
return lokalizacja;
}
public void setLokalizacja(String lokalizacja) {
this.lokalizacja = lokalizacja;
}
public String getTytul() {
return tytul;
}
public void setTytul(String tytul) {
this.tytul = tytul;
}
public String getOpis() {
return opis;
}
public void setOpis(String opis) {
this.opis = opis;
}
@Override
public String toString() {
return "Ogloszenie [id=" + idOgloszenia + ", wystawione=" + wystawione + ", cena=" + cena
+ ", lok=" + lokalizacja + ", opis=" + opis + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((cena == null) ? 0 : cena.hashCode());
result = prime * result + idOgloszenia;
result = prime * result + ((lokalizacja == null) ? 0 : lokalizacja.hashCode());
result = prime * result + ((opis == null) ? 0 : opis.hashCode());
result = prime * result + ((wystawione == null) ? 0 : wystawione.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Ogloszenie other = (Ogloszenie) obj;
if (cena == null) {
if (other.cena != null)
return false;
} else if (!cena.equals(other.cena))
return false;
if (idOgloszenia != other.idOgloszenia)
return false;
if (lokalizacja == null) {
if (other.lokalizacja != null)
return false;
} else if (!lokalizacja.equals(other.lokalizacja))
return false;
if (opis == null) {
if (other.opis != null)
return false;
} else if (!opis.equals(other.opis))
return false;
if (wystawione == null) {
if (other.wystawione != null)
return false;
} else if (!wystawione.equals(other.wystawione))
return false;
return true;
}
}
package ogloszenia.model;
import java.math.BigDecimal;
import java.time.LocalDateTime;
public class Samochodowe extends Ogloszenie {
private String marka;
private String model;
private String generacja;
private String kolor;
private int rocznik;
private int przebieg;
private float pojemnosc;
private float moc;
public Samochodowe() {
}
public Samochodowe(Integer idOgloszenia, Integer idSprzedawcy, LocalDateTime wystawione, BigDecimal cena,
String lokalizacja, String tytul, String opis, String marka, String model, String generacja, String kolor,
int rocznik, int przebieg, float pojemnosc, float moc) {
super(idOgloszenia, idSprzedawcy, wystawione, cena, lokalizacja, tytul, opis);
this.marka = marka;
this.model = model;
this.generacja = generacja;
this.kolor = kolor;
this.rocznik = rocznik;
this.przebieg = przebieg;
this.pojemnosc = pojemnosc;
this.moc = moc;
}
public String getMarka() {
return marka;
}
public void setMarka(String marka) {
this.marka = marka;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getGeneracja() {
return generacja;
}
public void setGeneracja(String generacja) {
this.generacja = generacja;
}
public String getKolor() {
return kolor;
}
public void setKolor(String kolor) {
this.kolor = kolor;
}
public int getRocznik() {
return rocznik;
}
public void setRocznik(int rocznik) {
this.rocznik = rocznik;
}
public int getPrzebieg() {
return przebieg;
}
public void setPrzebieg(int przebieg) {
this.przebieg = przebieg;
}
public float getPojemnosc() {
return pojemnosc;
}
// public void setPojemnosc(float pojemnosc) {
// this.pojemnosc = pojemnosc;
// }
public float getMoc() {
return moc;
}
// public void setMoc(float moc) {
// this.moc = moc;
// }
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((generacja == null) ? 0 : generacja.hashCode());
result = prime * result + ((kolor == null) ? 0 : kolor.hashCode());
result = prime * result + ((marka == null) ? 0 : marka.hashCode());
result = prime * result + Float.floatToIntBits(moc);
result = prime * result + ((model == null) ? 0 : model.hashCode());
result = prime * result + Float.floatToIntBits(pojemnosc);
result = prime * result + przebieg;
result = prime * result + rocznik;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
Samochodowe other = (Samochodowe) obj;
if (generacja == null) {
if (other.generacja != null)
return false;
} else if (!generacja.equals(other.generacja))
return false;
if (kolor == null) {
if (other.kolor != null)
return false;
} else if (!kolor.equals(other.kolor))
return false;
if (marka == null) {
if (other.marka != null)
return false;
} else if (!marka.equals(other.marka))
return false;
if (Float.floatToIntBits(moc) != Float.floatToIntBits(other.moc))
return false;
if (model == null) {
if (other.model != null)
return false;
} else if (!model.equals(other.model))
return false;
if (Float.floatToIntBits(pojemnosc) != Float.floatToIntBits(other.pojemnosc))
return false;
if (przebieg != other.przebieg)
return false;
if (rocznik != other.rocznik)
return false;
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder
.append("Ogl.Samochodowe [id=").append(getIdOgloszenia()).append(", idSprz=")
.append(getIdSprzedawcy()).append(", wystawione=").append(getWystawione()).append(", cena=")
.append(getCena()).append(", lok=").append(getLokalizacja()).append(", tytul=")
.append(getTytul()).append(", opis=").append(getOpis())
.append(", marka=").append(getMarka()).append(", model=").append(getModel())
.append(", gen=").append(getGeneracja()).append(", kolor=").append(getKolor())
.append(", rocznik=").append(getRocznik()).append(", przeb=").append(getPrzebieg())
.append(", poj=").append(getPojemnosc()).append(", moc=").append(getMoc()).append("]");
return builder.toString();
}
public String dajHtml() {
// String.format zwraca Stringa, a System.out.printf wypisuje na wyjście
return String.format("<div class='ogloszenie'>"
+ "<h2>%s</h2>"
+ "<p>Cena: <strong>%,.0f PLN</strong></p>"
+ "<p>Marka: %s %s %s</p>"
+ "<p>Silnik: %.1f l, %.0f KM</p>"
+ "</div>",
getTytul(),
getCena(),
getMarka(),
getModel(),
getGeneracja(),
getPojemnosc(),
getMoc()
);
}
}
package ogloszenia.model;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
public class Sprzedawca {
@XmlAttribute(name="id")
private int id_sprzedawcy;
private String nazwa;
private String ulica;
@XmlElement(name="kod-pocztowy")
private String kod_pocztowy;
private String miasto;
private String email;
private String telefon;
public Sprzedawca() {
}
public Sprzedawca(int id_sprzedawcy, String nazwa, String ulica, String kod_pocztowy, String miasto, String email,
String telefon) {
super();
this.id_sprzedawcy = id_sprzedawcy;
this.nazwa = nazwa;
this.ulica = ulica;
this.kod_pocztowy = kod_pocztowy;
this.miasto = miasto;
this.email = email;
this.telefon = telefon;
}
public int getId_sprzedawcy() {
return id_sprzedawcy;
}
public void setId_sprzedawcy(int id_sprzedawcy) {
this.id_sprzedawcy = id_sprzedawcy;
}
public String getNazwa() {
return nazwa.toUpperCase();
}
public void setNazwa(String nazwa) {
this.nazwa = nazwa;
}
public String getUlica() {
return ulica;
}
public void setUlica(String ulica) {
this.ulica = ulica;
}
public String getKod_pocztowy() {
return kod_pocztowy;
}
public void setKod_pocztowy(String kod_pocztowy) {
this.kod_pocztowy = kod_pocztowy;
}
public String getMiasto() {
return miasto;
}
public void setMiasto(String miasto) {
this.miasto = miasto;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTelefon() {
return telefon;
}
public void setTelefon(String telefon) {
this.telefon = telefon;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + id_sprzedawcy;
result = prime * result + ((kod_pocztowy == null) ? 0 : kod_pocztowy.hashCode());
result = prime * result + ((miasto == null) ? 0 : miasto.hashCode());
result = prime * result + ((nazwa == null) ? 0 : nazwa.hashCode());
result = prime * result + ((telefon == null) ? 0 : telefon.hashCode());
result = prime * result + ((ulica == null) ? 0 : ulica.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Sprzedawca other = (Sprzedawca) obj;
if (email == null) {
if (other.email != null)
return false;
} else if (!email.equals(other.email))
return false;
if (id_sprzedawcy != other.id_sprzedawcy)
return false;
if (kod_pocztowy == null) {
if (other.kod_pocztowy != null)
return false;
} else if (!kod_pocztowy.equals(other.kod_pocztowy))
return false;
if (miasto == null) {
if (other.miasto != null)
return false;
} else if (!miasto.equals(other.miasto))
return false;
if (nazwa == null) {
if (other.nazwa != null)
return false;
} else if (!nazwa.equals(other.nazwa))
return false;
if (telefon == null) {
if (other.telefon != null)
return false;
} else if (!telefon.equals(other.telefon))
return false;
if (ulica == null) {
if (other.ulica != null)
return false;
} else if (!ulica.equals(other.ulica))
return false;
return true;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Sprzedawca [id_sprzedawcy=").append(id_sprzedawcy).append(", nazwa=").append(nazwa)
.append(", ulica=").append(ulica).append(", kod_pocztowy=").append(kod_pocztowy).append(", miasto=")
.append(miasto).append(", email=").append(email).append(", telefon=").append(telefon).append("]");
return builder.toString();
}
}
@XmlAccessorType(XmlAccessType.FIELD)
package ogloszenia.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
package ogloszenia.soap;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.wss4j.common.ext.WSPasswordCallback;
public class PasswordCallback implements CallbackHandler {
private Map<String, String> passwords = new HashMap<String, String>();
public PasswordCallback() {
passwords.put("klient", "abc123");
passwords.put("serwer", "abc123");
}
/**
* It attempts to get the password from the private
* alias/passwords map.
*/
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
String pass = passwords.get(pc.getIdentifier());
if (pass != null) {
pc.setPassword(pass);
return;
}
}
}
/**
* Add an alias/password pair to the callback mechanism.
*/
public void setAliasPassword(String alias, String password) {
passwords.put(alias, password);
}
}
\ No newline at end of file
package ogloszenia.soap;
import java.math.BigDecimal;
import java.util.List;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.soap.MTOM;
import org.jboss.ws.api.annotation.EndpointConfig;
import ogloszenia.baza.DostepDoBazy;
import ogloszenia.baza.OgloszeniaDAO;
import ogloszenia.exn.BladBazyDanych;
import ogloszenia.exn.NieznanyRekord;
import ogloszenia.model.Samochodowe;
import ogloszenia.util.FotoUtil;
@WebService(wsdlLocation="WEB-INF/wsdl/SerwisOgloszeniowy.wsdl",
serviceName="SerwisOgloszeniowyService",
portName="SerwisOgloszeniowyPort",
name="SerwisOgloszeniowy",
targetNamespace="http://soap.ogloszenia/")
@EndpointConfig(configFile="WEB-INF/jaxws-endpoint-config.xml",
configName="Custom WS-Security Endpoint")
//@MTOM
public class SerwisOgloszeniowy {
@WebResult(name="ogloszenie")
public List<Samochodowe> wszystkieOgloszenia() throws BladBazyDanych {
try(DostepDoBazy db = new DostepDoBazy()) {
OgloszeniaDAO dao = db.ogloszeniaDAO();
return dao.odczytajWszystkie();
}
}
@WebResult(name="ogloszenie")
public List<Samochodowe> ogloszeniaWgCeny(
@WebParam(name="min") BigDecimal min,
@WebParam(name="max") BigDecimal max) throws BladBazyDanych {
try(DostepDoBazy db = new DostepDoBazy()) {
OgloszeniaDAO dao = db.ogloszeniaDAO();
return dao.odczytajWedlugCeny(min, max);
}
}
@WebResult(name="ogloszenie")
public Samochodowe ogloszenieWgId(@WebParam(name="id") int idOgloszenia) throws BladBazyDanych, NieznanyRekord {
try(DostepDoBazy db = new DostepDoBazy()) {
OgloszeniaDAO dao = db.ogloszeniaDAO();
return dao.odczytajWgId(idOgloszenia);
}
}
@WebResult(name="id")
public Integer zapiszOgloszenie(@WebParam(name="ogloszenie") Samochodowe ogl) throws BladBazyDanych {
try(DostepDoBazy db = new DostepDoBazy()) {
OgloszeniaDAO dao = db.ogloszeniaDAO();
dao.zapisz(ogl);
return ogl.getIdOgloszenia();
}
}
@WebResult(name="bajty")
public byte[] foto(@WebParam(name="id") int idOgloszenia) throws NieznanyRekord {
return FotoUtil.wczytajFoto(idOgloszenia);
}
}
package ogloszenia.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import ogloszenia.exn.NieznanyRekord;
public class FotoUtil {
public static byte[] wczytajFoto(int id) throws NieznanyRekord {
String katalog = Ustawienia.wczytaj().getProperty("katalog_foto");
String plik = id + ".jpg";
try {
byte[] dane = Files.readAllBytes(Paths.get(katalog, plik));
return dane;
} catch (IOException e) {
throw new NieznanyRekord("Brak pliku ze zdjęciem " + plik);
}
}
}
package ogloszenia.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Ustawienia {
/* stara wersja
public static Properties wczytaj() {
Properties p = new Properties();
p.setProperty("url", "jdbc:postgresql://localhost/ogloszenia");
p.setProperty("driver_class", "org.postgresql.Driver");
p.setProperty("user", "ogloszenia");
p.setProperty("password", "abc123");
return p;
}
*/
public static Properties wczytaj() {
Properties p = new Properties();
try (InputStream in = Ustawienia.class
.getResourceAsStream("/ustawienia.properties")) {
p.load(in);
} catch (IOException e) {
System.err.println("Nie mogę załadować properties " + e);
}
return p;
}
}
package ogloszenia.xml;
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import ogloszenia.baza.DostepDoBazy;
import ogloszenia.baza.OgloszeniaDAO;
import ogloszenia.exn.BladBazyDanych;
import ogloszenia.model.ListaOgloszen;
public class WypiszJAXB {
// Jak można wypisać dane w formacie XML za pomocą technologii JAXB
public static void main(String[] args) {
try {
ListaOgloszen lista = new ListaOgloszen();
try(DostepDoBazy db = new DostepDoBazy()) {
OgloszeniaDAO dao = db.ogloszeniaDAO();
lista.ogloszenia = dao.odczytajWszystkie();
}
JAXBContext ctx = JAXBContext.newInstance(ListaOgloszen.class);
Marshaller m = ctx.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(lista, new File("wynik.xml"));
System.out.println("Gotowe");
} catch (JAXBException e) {
e.printStackTrace();
} catch (BladBazyDanych e) {
e.printStackTrace();
}
}
}
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=abc123
org.apache.ws.security.crypto.merlin.keystore.alias=serwer
org.apache.ws.security.crypto.merlin.keystore.file=serwer.jks
\ No newline at end of file
url=jdbc:postgresql://localhost/ogloszenia
driver_class=org.postgresql.Driver
user=ogloszenia
password=abc123
tcpKeepAlive=true
katalog_foto=/home/patryk/ogloszenia/foto
<?xml version="1.0" encoding="UTF-8"?>
<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
<endpoint-config>
<config-name>Custom WS-Security Endpoint</config-name>
<property>
<property-name>ws-security.signature.properties</property-name>
<property-value>serwer.properties</property-value>
</property>
<property>
<property-name>ws-security.encryption.properties</property-name>
<property-value>serwer.properties</property-value>
</property>
<property>
<property-name>ws-security.signature.username</property-name>
<property-value>serwer</property-value>
</property>
<property>
<property-name>ws-security.encryption.username</property-name>
<property-value>klient</property-value>
</property>
<property>
<property-name>ws-security.callback-handler</property-name>
<property-value>ogloszenia.soap.PasswordCallback</property-value>
</property>
</endpoint-config>
</jaxws-config>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.vavatech.szkolenie.secure_soap</groupId>
<artifactId>P42-WSSec-Klient</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-stax</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-policy-stax</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-ws-security-common</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.wss4j</groupId>
<artifactId>wss4j-policy</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
</project>
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for BladBazyDanych complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="BladBazyDanych">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BladBazyDanych", propOrder = {
"message"
})
public class BladBazyDanych {
protected String message;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
package ogloszenia.generated;
import javax.xml.ws.WebFault;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebFault(name = "BladBazyDanych", targetNamespace = "http://soap.ogloszenia/")
public class BladBazyDanych_Exception
extends Exception
{
/**
* Java type that goes as soapenv:Fault detail element.
*
*/
private BladBazyDanych faultInfo;
/**
*
* @param faultInfo
* @param message
*/
public BladBazyDanych_Exception(String message, BladBazyDanych faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
/**
*
* @param faultInfo
* @param cause
* @param message
*/
public BladBazyDanych_Exception(String message, BladBazyDanych faultInfo, Throwable cause) {
super(message, cause);
this.faultInfo = faultInfo;
}
/**
*
* @return
* returns fault bean: ogloszenia.generated.BladBazyDanych
*/
public BladBazyDanych getFaultInfo() {
return faultInfo;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for foto complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="foto">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "foto", propOrder = {
"id"
})
public class Foto {
protected int id;
/**
* Gets the value of the id property.
*
*/
public int getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(int value) {
this.id = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for fotoResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="fotoResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="bajty" type="{http://www.w3.org/2001/XMLSchema}base64Binary" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "fotoResponse", propOrder = {
"bajty"
})
public class FotoResponse {
protected byte[] bajty;
/**
* Gets the value of the bajty property.
*
* @return
* possible object is
* byte[]
*/
public byte[] getBajty() {
return bajty;
}
/**
* Sets the value of the bajty property.
*
* @param value
* allowed object is
* byte[]
*/
public void setBajty(byte[] value) {
this.bajty = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for NieznanyRekord complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="NieznanyRekord">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NieznanyRekord", propOrder = {
"message"
})
public class NieznanyRekord {
protected String message;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
package ogloszenia.generated;
import javax.xml.ws.WebFault;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebFault(name = "NieznanyRekord", targetNamespace = "http://soap.ogloszenia/")
public class NieznanyRekord_Exception
extends Exception
{
/**
* Java type that goes as soapenv:Fault detail element.
*
*/
private NieznanyRekord faultInfo;
/**
*
* @param faultInfo
* @param message
*/
public NieznanyRekord_Exception(String message, NieznanyRekord faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
/**
*
* @param faultInfo
* @param cause
* @param message
*/
public NieznanyRekord_Exception(String message, NieznanyRekord faultInfo, Throwable cause) {
super(message, cause);
this.faultInfo = faultInfo;
}
/**
*
* @return
* returns fault bean: ogloszenia.generated.NieznanyRekord
*/
public NieznanyRekord getFaultInfo() {
return faultInfo;
}
}
package ogloszenia.generated;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ogloszeniaWgCeny complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ogloszeniaWgCeny">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="min" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
* &lt;element name="max" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ogloszeniaWgCeny", propOrder = {
"min",
"max"
})
public class OgloszeniaWgCeny {
protected BigDecimal min;
protected BigDecimal max;
/**
* Gets the value of the min property.
*
* @return
* possible object is
* {@link BigDecimal }
*
*/
public BigDecimal getMin() {
return min;
}
/**
* Sets the value of the min property.
*
* @param value
* allowed object is
* {@link BigDecimal }
*
*/
public void setMin(BigDecimal value) {
this.min = value;
}
/**
* Gets the value of the max property.
*
* @return
* possible object is
* {@link BigDecimal }
*
*/
public BigDecimal getMax() {
return max;
}
/**
* Sets the value of the max property.
*
* @param value
* allowed object is
* {@link BigDecimal }
*
*/
public void setMax(BigDecimal value) {
this.max = value;
}
}
package ogloszenia.generated;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ogloszeniaWgCenyResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ogloszeniaWgCenyResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="ogloszenie" type="{http://soap.ogloszenia/}samochodowe" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ogloszeniaWgCenyResponse", propOrder = {
"ogloszenie"
})
public class OgloszeniaWgCenyResponse {
protected List<Samochodowe> ogloszenie;
/**
* Gets the value of the ogloszenie property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ogloszenie property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getOgloszenie().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Samochodowe }
*
*
*/
public List<Samochodowe> getOgloszenie() {
if (ogloszenie == null) {
ogloszenie = new ArrayList<Samochodowe>();
}
return this.ogloszenie;
}
}
package ogloszenia.generated;
import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ogloszenie complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ogloszenie">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="wystawione" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="cena" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
* &lt;element name="lokalizacja" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="tytul" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="opis" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="sprzedawca" type="{http://soap.ogloszenia/}sprzedawca" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;attribute name="id-sprzedawcy" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ogloszenie", propOrder = {
"wystawione",
"cena",
"lokalizacja",
"tytul",
"opis",
"sprzedawca"
})
@XmlSeeAlso({
Samochodowe.class
})
public class Ogloszenie {
protected String wystawione;
protected BigDecimal cena;
protected String lokalizacja;
protected String tytul;
protected String opis;
protected Sprzedawca sprzedawca;
@XmlAttribute(name = "id")
protected Integer id;
@XmlAttribute(name = "id-sprzedawcy")
protected Integer idSprzedawcy;
/**
* Gets the value of the wystawione property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getWystawione() {
return wystawione;
}
/**
* Sets the value of the wystawione property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setWystawione(String value) {
this.wystawione = value;
}
/**
* Gets the value of the cena property.
*
* @return
* possible object is
* {@link BigDecimal }
*
*/
public BigDecimal getCena() {
return cena;
}
/**
* Sets the value of the cena property.
*
* @param value
* allowed object is
* {@link BigDecimal }
*
*/
public void setCena(BigDecimal value) {
this.cena = value;
}
/**
* Gets the value of the lokalizacja property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLokalizacja() {
return lokalizacja;
}
/**
* Sets the value of the lokalizacja property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLokalizacja(String value) {
this.lokalizacja = value;
}
/**
* Gets the value of the tytul property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTytul() {
return tytul;
}
/**
* Sets the value of the tytul property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTytul(String value) {
this.tytul = value;
}
/**
* Gets the value of the opis property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getOpis() {
return opis;
}
/**
* Sets the value of the opis property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setOpis(String value) {
this.opis = value;
}
/**
* Gets the value of the sprzedawca property.
*
* @return
* possible object is
* {@link Sprzedawca }
*
*/
public Sprzedawca getSprzedawca() {
return sprzedawca;
}
/**
* Sets the value of the sprzedawca property.
*
* @param value
* allowed object is
* {@link Sprzedawca }
*
*/
public void setSprzedawca(Sprzedawca value) {
this.sprzedawca = value;
}
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setId(Integer value) {
this.id = value;
}
/**
* Gets the value of the idSprzedawcy property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getIdSprzedawcy() {
return idSprzedawcy;
}
/**
* Sets the value of the idSprzedawcy property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setIdSprzedawcy(Integer value) {
this.idSprzedawcy = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ogloszenieWgId complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ogloszenieWgId">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ogloszenieWgId", propOrder = {
"id"
})
public class OgloszenieWgId {
protected int id;
/**
* Gets the value of the id property.
*
*/
public int getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(int value) {
this.id = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ogloszenieWgIdResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ogloszenieWgIdResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="ogloszenie" type="{http://soap.ogloszenia/}samochodowe" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ogloszenieWgIdResponse", propOrder = {
"ogloszenie"
})
public class OgloszenieWgIdResponse {
protected Samochodowe ogloszenie;
/**
* Gets the value of the ogloszenie property.
*
* @return
* possible object is
* {@link Samochodowe }
*
*/
public Samochodowe getOgloszenie() {
return ogloszenie;
}
/**
* Sets the value of the ogloszenie property.
*
* @param value
* allowed object is
* {@link Samochodowe }
*
*/
public void setOgloszenie(Samochodowe value) {
this.ogloszenie = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for samochodowe complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="samochodowe">
* &lt;complexContent>
* &lt;extension base="{http://soap.ogloszenia/}ogloszenie">
* &lt;sequence>
* &lt;element name="marka" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="model" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="generacja" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="kolor" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="rocznik" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="przebieg" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="pojemnosc" type="{http://www.w3.org/2001/XMLSchema}float"/>
* &lt;element name="moc" type="{http://www.w3.org/2001/XMLSchema}float"/>
* &lt;/sequence>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "samochodowe", propOrder = {
"marka",
"model",
"generacja",
"kolor",
"rocznik",
"przebieg",
"pojemnosc",
"moc"
})
public class Samochodowe
extends Ogloszenie
{
protected String marka;
protected String model;
protected String generacja;
protected String kolor;
protected int rocznik;
protected int przebieg;
protected float pojemnosc;
protected float moc;
/**
* Gets the value of the marka property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMarka() {
return marka;
}
/**
* Sets the value of the marka property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMarka(String value) {
this.marka = value;
}
/**
* Gets the value of the model property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getModel() {
return model;
}
/**
* Sets the value of the model property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setModel(String value) {
this.model = value;
}
/**
* Gets the value of the generacja property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getGeneracja() {
return generacja;
}
/**
* Sets the value of the generacja property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setGeneracja(String value) {
this.generacja = value;
}
/**
* Gets the value of the kolor property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getKolor() {
return kolor;
}
/**
* Sets the value of the kolor property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setKolor(String value) {
this.kolor = value;
}
/**
* Gets the value of the rocznik property.
*
*/
public int getRocznik() {
return rocznik;
}
/**
* Sets the value of the rocznik property.
*
*/
public void setRocznik(int value) {
this.rocznik = value;
}
/**
* Gets the value of the przebieg property.
*
*/
public int getPrzebieg() {
return przebieg;
}
/**
* Sets the value of the przebieg property.
*
*/
public void setPrzebieg(int value) {
this.przebieg = value;
}
/**
* Gets the value of the pojemnosc property.
*
*/
public float getPojemnosc() {
return pojemnosc;
}
/**
* Sets the value of the pojemnosc property.
*
*/
public void setPojemnosc(float value) {
this.pojemnosc = value;
}
/**
* Gets the value of the moc property.
*
*/
public float getMoc() {
return moc;
}
/**
* Sets the value of the moc property.
*
*/
public void setMoc(float value) {
this.moc = value;
}
}
package ogloszenia.generated;
import java.math.BigDecimal;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebService(name = "SerwisOgloszeniowy", targetNamespace = "http://soap.ogloszenia/")
@XmlSeeAlso({
ObjectFactory.class
})
public interface SerwisOgloszeniowy {
/**
*
* @param ogloszenie
* @return
* returns java.lang.Integer
* @throws BladBazyDanych_Exception
*/
@WebMethod
@WebResult(name = "id", targetNamespace = "")
@RequestWrapper(localName = "zapiszOgloszenie", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.ZapiszOgloszenie")
@ResponseWrapper(localName = "zapiszOgloszenieResponse", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.ZapiszOgloszenieResponse")
public Integer zapiszOgloszenie(
@WebParam(name = "ogloszenie", targetNamespace = "")
Samochodowe ogloszenie)
throws BladBazyDanych_Exception
;
/**
*
* @param id
* @return
* returns byte[]
* @throws NieznanyRekord_Exception
*/
@WebMethod
@WebResult(name = "bajty", targetNamespace = "")
@RequestWrapper(localName = "foto", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.Foto")
@ResponseWrapper(localName = "fotoResponse", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.FotoResponse")
public byte[] foto(
@WebParam(name = "id", targetNamespace = "")
int id)
throws NieznanyRekord_Exception
;
/**
*
* @param min
* @param max
* @return
* returns java.util.List<ogloszenia.generated.Samochodowe>
* @throws BladBazyDanych_Exception
*/
@WebMethod
@WebResult(name = "ogloszenie", targetNamespace = "")
@RequestWrapper(localName = "ogloszeniaWgCeny", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.OgloszeniaWgCeny")
@ResponseWrapper(localName = "ogloszeniaWgCenyResponse", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.OgloszeniaWgCenyResponse")
public List<Samochodowe> ogloszeniaWgCeny(
@WebParam(name = "min", targetNamespace = "")
BigDecimal min,
@WebParam(name = "max", targetNamespace = "")
BigDecimal max)
throws BladBazyDanych_Exception
;
/**
*
* @param id
* @return
* returns ogloszenia.generated.Samochodowe
* @throws NieznanyRekord_Exception
* @throws BladBazyDanych_Exception
*/
@WebMethod
@WebResult(name = "ogloszenie", targetNamespace = "")
@RequestWrapper(localName = "ogloszenieWgId", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.OgloszenieWgId")
@ResponseWrapper(localName = "ogloszenieWgIdResponse", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.OgloszenieWgIdResponse")
public Samochodowe ogloszenieWgId(
@WebParam(name = "id", targetNamespace = "")
int id)
throws BladBazyDanych_Exception, NieznanyRekord_Exception
;
/**
*
* @return
* returns java.util.List<ogloszenia.generated.Samochodowe>
* @throws BladBazyDanych_Exception
*/
@WebMethod
@WebResult(name = "ogloszenie", targetNamespace = "")
@RequestWrapper(localName = "wszystkieOgloszenia", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.WszystkieOgloszenia")
@ResponseWrapper(localName = "wszystkieOgloszeniaResponse", targetNamespace = "http://soap.ogloszenia/", className = "ogloszenia.generated.WszystkieOgloszeniaResponse")
public List<Samochodowe> wszystkieOgloszenia()
throws BladBazyDanych_Exception
;
}
package ogloszenia.generated;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "SerwisOgloszeniowyService", targetNamespace = "http://soap.ogloszenia/", wsdlLocation = "http://localhost:8080/P41-WSSec-Serwer-1.0/SerwisOgloszeniowyService?wsdl")
public class SerwisOgloszeniowyService
extends Service
{
private final static URL SERWISOGLOSZENIOWYSERVICE_WSDL_LOCATION;
private final static WebServiceException SERWISOGLOSZENIOWYSERVICE_EXCEPTION;
private final static QName SERWISOGLOSZENIOWYSERVICE_QNAME = new QName("http://soap.ogloszenia/", "SerwisOgloszeniowyService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("http://localhost:8080/P41-WSSec-Serwer-1.0/SerwisOgloszeniowyService?wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
SERWISOGLOSZENIOWYSERVICE_WSDL_LOCATION = url;
SERWISOGLOSZENIOWYSERVICE_EXCEPTION = e;
}
public SerwisOgloszeniowyService() {
super(__getWsdlLocation(), SERWISOGLOSZENIOWYSERVICE_QNAME);
}
public SerwisOgloszeniowyService(WebServiceFeature... features) {
super(__getWsdlLocation(), SERWISOGLOSZENIOWYSERVICE_QNAME, features);
}
public SerwisOgloszeniowyService(URL wsdlLocation) {
super(wsdlLocation, SERWISOGLOSZENIOWYSERVICE_QNAME);
}
public SerwisOgloszeniowyService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, SERWISOGLOSZENIOWYSERVICE_QNAME, features);
}
public SerwisOgloszeniowyService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public SerwisOgloszeniowyService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns SerwisOgloszeniowy
*/
@WebEndpoint(name = "SerwisOgloszeniowyPort")
public SerwisOgloszeniowy getSerwisOgloszeniowyPort() {
return super.getPort(new QName("http://soap.ogloszenia/", "SerwisOgloszeniowyPort"), SerwisOgloszeniowy.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns SerwisOgloszeniowy
*/
@WebEndpoint(name = "SerwisOgloszeniowyPort")
public SerwisOgloszeniowy getSerwisOgloszeniowyPort(WebServiceFeature... features) {
return super.getPort(new QName("http://soap.ogloszenia/", "SerwisOgloszeniowyPort"), SerwisOgloszeniowy.class, features);
}
private static URL __getWsdlLocation() {
if (SERWISOGLOSZENIOWYSERVICE_EXCEPTION!= null) {
throw SERWISOGLOSZENIOWYSERVICE_EXCEPTION;
}
return SERWISOGLOSZENIOWYSERVICE_WSDL_LOCATION;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for sprzedawca complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="sprzedawca">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="nazwa" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="ulica" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="kod-pocztowy" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="miasto" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="email" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="telefon" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sprzedawca", propOrder = {
"nazwa",
"ulica",
"kodPocztowy",
"miasto",
"email",
"telefon"
})
public class Sprzedawca {
protected String nazwa;
protected String ulica;
@XmlElement(name = "kod-pocztowy")
protected String kodPocztowy;
protected String miasto;
protected String email;
protected String telefon;
@XmlAttribute(name = "id", required = true)
protected int id;
/**
* Gets the value of the nazwa property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNazwa() {
return nazwa;
}
/**
* Sets the value of the nazwa property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNazwa(String value) {
this.nazwa = value;
}
/**
* Gets the value of the ulica property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getUlica() {
return ulica;
}
/**
* Sets the value of the ulica property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setUlica(String value) {
this.ulica = value;
}
/**
* Gets the value of the kodPocztowy property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getKodPocztowy() {
return kodPocztowy;
}
/**
* Sets the value of the kodPocztowy property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setKodPocztowy(String value) {
this.kodPocztowy = value;
}
/**
* Gets the value of the miasto property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMiasto() {
return miasto;
}
/**
* Sets the value of the miasto property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMiasto(String value) {
this.miasto = value;
}
/**
* Gets the value of the email property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getEmail() {
return email;
}
/**
* Sets the value of the email property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setEmail(String value) {
this.email = value;
}
/**
* Gets the value of the telefon property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTelefon() {
return telefon;
}
/**
* Sets the value of the telefon property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTelefon(String value) {
this.telefon = value;
}
/**
* Gets the value of the id property.
*
*/
public int getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(int value) {
this.id = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for wszystkieOgloszenia complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="wszystkieOgloszenia">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "wszystkieOgloszenia")
public class WszystkieOgloszenia {
}
package ogloszenia.generated;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for wszystkieOgloszeniaResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="wszystkieOgloszeniaResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="ogloszenie" type="{http://soap.ogloszenia/}samochodowe" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "wszystkieOgloszeniaResponse", propOrder = {
"ogloszenie"
})
public class WszystkieOgloszeniaResponse {
protected List<Samochodowe> ogloszenie;
/**
* Gets the value of the ogloszenie property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the ogloszenie property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getOgloszenie().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Samochodowe }
*
*
*/
public List<Samochodowe> getOgloszenie() {
if (ogloszenie == null) {
ogloszenie = new ArrayList<Samochodowe>();
}
return this.ogloszenie;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for zapiszOgloszenie complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="zapiszOgloszenie">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="ogloszenie" type="{http://soap.ogloszenia/}samochodowe" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "zapiszOgloszenie", propOrder = {
"ogloszenie"
})
public class ZapiszOgloszenie {
protected Samochodowe ogloszenie;
/**
* Gets the value of the ogloszenie property.
*
* @return
* possible object is
* {@link Samochodowe }
*
*/
public Samochodowe getOgloszenie() {
return ogloszenie;
}
/**
* Sets the value of the ogloszenie property.
*
* @param value
* allowed object is
* {@link Samochodowe }
*
*/
public void setOgloszenie(Samochodowe value) {
this.ogloszenie = value;
}
}
package ogloszenia.generated;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for zapiszOgloszenieResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="zapiszOgloszenieResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "zapiszOgloszenieResponse", propOrder = {
"id"
})
public class ZapiszOgloszenieResponse {
protected Integer id;
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setId(Integer value) {
this.id = value;
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://soap.ogloszenia/")
package ogloszenia.generated;
package ogloszenia.klient;
import java.util.List;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.ws.security.SecurityConstants;
import ogloszenia.generated.BladBazyDanych_Exception;
import ogloszenia.generated.Samochodowe;
import ogloszenia.generated.SerwisOgloszeniowy;
import ogloszenia.generated.SerwisOgloszeniowyService;
public class Klient1 {
public static void main(String[] args) {
SerwisOgloszeniowyService service = new SerwisOgloszeniowyService();
SerwisOgloszeniowy proxy = service.getSerwisOgloszeniowyPort();
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new PasswordCallback());
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/klient.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/klient.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "klient");
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "serwer");
try {
List<Samochodowe> ogloszenia = proxy.wszystkieOgloszenia();
System.out.println("Odczytano " + ogloszenia.size() + " ogłoszeń");
for (Samochodowe ogl : ogloszenia) {
System.out.println(ogl.getTytul() + " " + ogl.getCena());
}
} catch (BladBazyDanych_Exception e) {
e.printStackTrace();
}
}
}
package ogloszenia.klient;
import javax.swing.JOptionPane;
import javax.xml.ws.BindingProvider;
import org.apache.cxf.ws.security.SecurityConstants;
import ogloszenia.generated.BladBazyDanych_Exception;
import ogloszenia.generated.NieznanyRekord_Exception;
import ogloszenia.generated.Samochodowe;
import ogloszenia.generated.SerwisOgloszeniowy;
import ogloszenia.generated.SerwisOgloszeniowyService;
public class Klient2 {
public static void main(String[] args) {
SerwisOgloszeniowyService service = new SerwisOgloszeniowyService();
SerwisOgloszeniowy proxy = service.getSerwisOgloszeniowyPort();
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new PasswordCallback());
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/klient.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/klient.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "klient");
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "serwer");
while(true) {
String input = JOptionPane.showInputDialog("Podaj id ogłoszenia");
if(input == null)
break;
int id = Integer.parseInt(input);
try {
Samochodowe ogl = proxy.ogloszenieWgId(id);
// ogłoszenie znalezione
System.out.println(ogl.getId() +" " + ogl.getTytul() + " " + ogl.getCena());
System.out.println(ogl.getMarka() + " " + ogl.getModel() + " rocznik " + ogl.getRocznik());
System.out.println(ogl.getOpis());
} catch (BladBazyDanych_Exception e) {
e.printStackTrace();
} catch (NieznanyRekord_Exception e) {
System.out.println(e);
}
System.out.println();
}
}
}
package ogloszenia.klient;
import java.util.List;
import ogloszenia.generated.BladBazyDanych_Exception;
import ogloszenia.generated.Samochodowe;
import ogloszenia.generated.SerwisOgloszeniowy;
import ogloszenia.generated.SerwisOgloszeniowyService;
public class Klient_Niezabezpieczony {
public static void main(String[] args) {
SerwisOgloszeniowyService service = new SerwisOgloszeniowyService();
SerwisOgloszeniowy proxy = service.getSerwisOgloszeniowyPort();
try {
List<Samochodowe> ogloszenia = proxy.wszystkieOgloszenia();
System.out.println("Odczytano " + ogloszenia.size() + " ogłoszeń");
for (Samochodowe ogl : ogloszenia) {
System.out.println(ogl.getTytul() + " " + ogl.getCena());
}
} catch (BladBazyDanych_Exception e) {
e.printStackTrace();
}
}
}
package ogloszenia.klient;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.wss4j.common.ext.WSPasswordCallback;
public class PasswordCallback implements CallbackHandler {
private Map<String, String> passwords = new HashMap<String, String>();
public PasswordCallback() {
passwords.put("klient", "abc123");
passwords.put("serwer", "abc123");
}
/**
* It attempts to get the password from the private
* alias/passwords map.
*/
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
String pass = passwords.get(pc.getIdentifier());
if (pass != null) {
pc.setPassword(pass);
return;
}
}
}
/**
* Add an alias/password pair to the callback mechanism.
*/
public void setAliasPassword(String alias, String password) {
passwords.put(alias, password);
}
}
\ No newline at end of file
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=abc123
org.apache.ws.security.crypto.merlin.keystore.alias=klient
org.apache.ws.security.crypto.merlin.keystore.file=META-INF/klient.jks
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment