BAEL-1174: A Quick Guide to Spring Cloud Consul
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Eugen Paraschiv
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -14,3 +14,4 @@
|
||||
- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort)
|
||||
- [Introduction to JGraphT](http://www.baeldung.com/jgrapht)
|
||||
- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm)
|
||||
- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.baeldung.algorithms.prime;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class PrimeGenerator {
|
||||
public static List<Integer> sieveOfEratosthenes(int n) {
|
||||
final boolean prime[] = new boolean[n + 1];
|
||||
Arrays.fill(prime, true);
|
||||
|
||||
for (int p = 2; p * p <= n; p++) {
|
||||
if (prime[p]) {
|
||||
for (int i = p * 2; i <= n; i += p)
|
||||
prime[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
final List<Integer> primes = new LinkedList<>();
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (prime[i])
|
||||
primes.add(i);
|
||||
}
|
||||
return primes;
|
||||
}
|
||||
|
||||
public static List<Integer> primeNumbersBruteForce(int max) {
|
||||
final List<Integer> primeNumbers = new LinkedList<Integer>();
|
||||
for (int i = 2; i <= max; i++) {
|
||||
if (isPrimeBruteForce(i)) {
|
||||
primeNumbers.add(i);
|
||||
}
|
||||
}
|
||||
return primeNumbers;
|
||||
}
|
||||
|
||||
private static boolean isPrimeBruteForce(int x) {
|
||||
for (int i = 2; i < x; i++) {
|
||||
if (x % i == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<Integer> primeNumbersTill(int max) {
|
||||
return IntStream.rangeClosed(2, max)
|
||||
.filter(x -> isPrime(x))
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static boolean isPrime(int x) {
|
||||
return IntStream.rangeClosed(2, (int) (Math.sqrt(x)))
|
||||
.allMatch(n -> x % n != 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.algorithms.prime;
|
||||
|
||||
import static com.baeldung.algorithms.prime.PrimeGenerator.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PrimeGeneratorTest {
|
||||
@Test
|
||||
public void whenBruteForced_returnsSuccessfully() {
|
||||
final List<Integer> primeNumbers = primeNumbersBruteForce(20);
|
||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenOptimized_returnsSuccessfully() {
|
||||
final List<Integer> primeNumbers = primeNumbersTill(20);
|
||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSieveOfEratosthenes_returnsSuccessfully() {
|
||||
final List<Integer> primeNumbers = sieveOfEratosthenes(20);
|
||||
assertEquals(Arrays.asList(new Integer[] { 2, 3, 5, 7, 11, 13, 17, 19 }), primeNumbers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.baeldung.poi.powerpoint;
|
||||
|
||||
import org.apache.poi.sl.usermodel.AutoNumberingScheme;
|
||||
import org.apache.poi.sl.usermodel.PictureData;
|
||||
import org.apache.poi.sl.usermodel.TableCell;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xslf.usermodel.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper class for the PowerPoint presentation creation
|
||||
*/
|
||||
public class PowerPointHelper {
|
||||
|
||||
/**
|
||||
* Read an existing presentation
|
||||
*
|
||||
* @param fileLocation
|
||||
* File location of the presentation
|
||||
* @return instance of {@link XMLSlideShow}
|
||||
* @throws IOException
|
||||
*/
|
||||
public XMLSlideShow readingExistingSlideShow(String fileLocation) throws IOException {
|
||||
return new XMLSlideShow(new FileInputStream(fileLocation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a sample presentation
|
||||
*
|
||||
* @param fileLocation
|
||||
* File location of the presentation
|
||||
* @throws IOException
|
||||
*/
|
||||
public void createPresentation(String fileLocation) throws IOException {
|
||||
// Create presentation
|
||||
XMLSlideShow ppt = new XMLSlideShow();
|
||||
|
||||
XSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
|
||||
|
||||
// Retriving the slide layout
|
||||
XSLFSlideLayout layout = defaultMaster.getLayout(SlideLayout.TITLE_ONLY);
|
||||
|
||||
// Creating the 1st slide
|
||||
XSLFSlide slide1 = ppt.createSlide(layout);
|
||||
XSLFTextShape title = slide1.getPlaceholder(0);
|
||||
// Clearing text to remove the predefined one in the template
|
||||
title.clearText();
|
||||
XSLFTextParagraph p = title.addNewTextParagraph();
|
||||
|
||||
XSLFTextRun r1 = p.addNewTextRun();
|
||||
r1.setText("Baeldung");
|
||||
r1.setFontColor(new Color(78, 147, 89));
|
||||
r1.setFontSize(48.);
|
||||
|
||||
// Add Image
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
byte[] pictureData = IOUtils.toByteArray(new FileInputStream(classLoader.getResource("logo-leaf.png").getFile()));
|
||||
|
||||
XSLFPictureData pd = ppt.addPicture(pictureData, PictureData.PictureType.PNG);
|
||||
XSLFPictureShape picture = slide1.createPicture(pd);
|
||||
picture.setAnchor(new Rectangle(320, 230, 100, 92));
|
||||
|
||||
// Creating 2nd slide
|
||||
layout = defaultMaster.getLayout(SlideLayout.TITLE_AND_CONTENT);
|
||||
XSLFSlide slide2 = ppt.createSlide(layout);
|
||||
|
||||
// setting the tile
|
||||
title = slide2.getPlaceholder(0);
|
||||
title.clearText();
|
||||
XSLFTextRun r = title.addNewTextParagraph().addNewTextRun();
|
||||
r.setText("Baeldung");
|
||||
|
||||
// Adding the link
|
||||
XSLFHyperlink link = r.createHyperlink();
|
||||
link.setAddress("http://www.baeldung.com");
|
||||
|
||||
// setting the content
|
||||
XSLFTextShape content = slide2.getPlaceholder(1);
|
||||
content.clearText(); // unset any existing text
|
||||
content.addNewTextParagraph().addNewTextRun().setText("First paragraph");
|
||||
content.addNewTextParagraph().addNewTextRun().setText("Second paragraph");
|
||||
content.addNewTextParagraph().addNewTextRun().setText("Third paragraph");
|
||||
|
||||
// Creating 3rd slide - List
|
||||
layout = defaultMaster.getLayout(SlideLayout.TITLE_AND_CONTENT);
|
||||
XSLFSlide slide3 = ppt.createSlide(layout);
|
||||
title = slide3.getPlaceholder(0);
|
||||
title.clearText();
|
||||
r = title.addNewTextParagraph().addNewTextRun();
|
||||
r.setText("Lists");
|
||||
|
||||
content = slide3.getPlaceholder(1);
|
||||
content.clearText();
|
||||
XSLFTextParagraph p1 = content.addNewTextParagraph();
|
||||
p1.setIndentLevel(0);
|
||||
p1.setBullet(true);
|
||||
r1 = p1.addNewTextRun();
|
||||
r1.setText("Bullet");
|
||||
|
||||
// the next three paragraphs form an auto-numbered list
|
||||
XSLFTextParagraph p2 = content.addNewTextParagraph();
|
||||
p2.setBulletAutoNumber(AutoNumberingScheme.alphaLcParenRight, 1);
|
||||
p2.setIndentLevel(1);
|
||||
XSLFTextRun r2 = p2.addNewTextRun();
|
||||
r2.setText("Numbered List Item - 1");
|
||||
|
||||
// Creating 4th slide
|
||||
XSLFSlide slide4 = ppt.createSlide();
|
||||
createTable(slide4);
|
||||
|
||||
// Save presentation
|
||||
FileOutputStream out = new FileOutputStream(fileLocation);
|
||||
ppt.write(out);
|
||||
out.close();
|
||||
|
||||
// Closing presentation
|
||||
ppt.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a slide from the presentation
|
||||
*
|
||||
* @param ppt
|
||||
* The presentation
|
||||
* @param slideNumber
|
||||
* The number of the slide to be deleted (0-based)
|
||||
*/
|
||||
public void deleteSlide(XMLSlideShow ppt, int slideNumber) {
|
||||
ppt.removeSlide(slideNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-order the slides inside a presentation
|
||||
*
|
||||
* @param ppt
|
||||
* The presentation
|
||||
* @param slideNumber
|
||||
* The number of the slide to move
|
||||
* @param newSlideNumber
|
||||
* The new position of the slide (0-base)
|
||||
*/
|
||||
public void reorderSlide(XMLSlideShow ppt, int slideNumber, int newSlideNumber) {
|
||||
List<XSLFSlide> slides = ppt.getSlides();
|
||||
|
||||
XSLFSlide secondSlide = slides.get(slideNumber);
|
||||
ppt.setSlideOrder(secondSlide, newSlideNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the placeholder inside a slide
|
||||
*
|
||||
* @param slide
|
||||
* The slide
|
||||
* @return List of placeholder inside a slide
|
||||
*/
|
||||
public List<XSLFShape> retrieveTemplatePlaceholders(XSLFSlide slide) {
|
||||
List<XSLFShape> placeholders = new ArrayList<>();
|
||||
|
||||
for (XSLFShape shape : slide.getShapes()) {
|
||||
if (shape instanceof XSLFAutoShape) {
|
||||
placeholders.add(shape);
|
||||
}
|
||||
}
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a table
|
||||
*
|
||||
* @param slide
|
||||
* Slide
|
||||
*/
|
||||
private void createTable(XSLFSlide slide) {
|
||||
|
||||
XSLFTable tbl = slide.createTable();
|
||||
tbl.setAnchor(new Rectangle(50, 50, 450, 300));
|
||||
|
||||
int numColumns = 3;
|
||||
int numRows = 5;
|
||||
|
||||
// header
|
||||
XSLFTableRow headerRow = tbl.addRow();
|
||||
headerRow.setHeight(50);
|
||||
for (int i = 0; i < numColumns; i++) {
|
||||
XSLFTableCell th = headerRow.addCell();
|
||||
XSLFTextParagraph p = th.addNewTextParagraph();
|
||||
p.setTextAlign(TextParagraph.TextAlign.CENTER);
|
||||
XSLFTextRun r = p.addNewTextRun();
|
||||
r.setText("Header " + (i + 1));
|
||||
r.setBold(true);
|
||||
r.setFontColor(Color.white);
|
||||
th.setFillColor(new Color(79, 129, 189));
|
||||
th.setBorderWidth(TableCell.BorderEdge.bottom, 2.0);
|
||||
th.setBorderColor(TableCell.BorderEdge.bottom, Color.white);
|
||||
// all columns are equally sized
|
||||
tbl.setColumnWidth(i, 150);
|
||||
}
|
||||
|
||||
// data
|
||||
for (int rownum = 0; rownum < numRows; rownum++) {
|
||||
XSLFTableRow tr = tbl.addRow();
|
||||
tr.setHeight(50);
|
||||
for (int i = 0; i < numColumns; i++) {
|
||||
XSLFTableCell cell = tr.addCell();
|
||||
XSLFTextParagraph p = cell.addNewTextParagraph();
|
||||
XSLFTextRun r = p.addNewTextRun();
|
||||
|
||||
r.setText("Cell " + (i * rownum + 1));
|
||||
if (rownum % 2 == 0) {
|
||||
cell.setFillColor(new Color(208, 216, 232));
|
||||
} else {
|
||||
cell.setFillColor(new Color(233, 247, 244));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.baeldung.poi.powerpoint;
|
||||
|
||||
import org.apache.poi.xslf.usermodel.XMLSlideShow;
|
||||
import org.apache.poi.xslf.usermodel.XSLFShape;
|
||||
import org.apache.poi.xslf.usermodel.XSLFSlide;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class PowerPointIntegrationTest {
|
||||
|
||||
private PowerPointHelper pph;
|
||||
private String fileLocation;
|
||||
private static final String FILE_NAME = "presentation.pptx";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
File currDir = new File(".");
|
||||
String path = currDir.getAbsolutePath();
|
||||
fileLocation = path.substring(0, path.length() - 1) + FILE_NAME;
|
||||
|
||||
pph = new PowerPointHelper();
|
||||
pph.createPresentation(fileLocation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenReadingAPresentation_thenOK() throws Exception {
|
||||
XMLSlideShow xmlSlideShow = pph.readingExistingSlideShow(fileLocation);
|
||||
|
||||
Assert.assertNotNull(xmlSlideShow);
|
||||
Assert.assertEquals(4, xmlSlideShow.getSlides().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenRetrievingThePlaceholdersForEachSlide_thenOK() throws Exception {
|
||||
XMLSlideShow xmlSlideShow = pph.readingExistingSlideShow(fileLocation);
|
||||
|
||||
List<XSLFShape> onlyTitleSlidePlaceholders = pph.retrieveTemplatePlaceholders(xmlSlideShow.getSlides().get(0));
|
||||
List<XSLFShape> titleAndBodySlidePlaceholders = pph.retrieveTemplatePlaceholders(xmlSlideShow.getSlides().get(1));
|
||||
List<XSLFShape> emptySlidePlaceholdes = pph.retrieveTemplatePlaceholders(xmlSlideShow.getSlides().get(3));
|
||||
|
||||
Assert.assertEquals(1, onlyTitleSlidePlaceholders.size());
|
||||
Assert.assertEquals(2, titleAndBodySlidePlaceholders.size());
|
||||
Assert.assertEquals(0, emptySlidePlaceholdes.size());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenSortingSlides_thenOK() throws Exception {
|
||||
XMLSlideShow xmlSlideShow = pph.readingExistingSlideShow(fileLocation);
|
||||
XSLFSlide slide4 = xmlSlideShow.getSlides().get(3);
|
||||
pph.reorderSlide(xmlSlideShow, 3, 1);
|
||||
|
||||
Assert.assertEquals(slide4, xmlSlideShow.getSlides().get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenPresentation_whenDeletingASlide_thenOK() throws Exception {
|
||||
XMLSlideShow xmlSlideShow = pph.readingExistingSlideShow(fileLocation);
|
||||
pph.deleteSlide(xmlSlideShow, 3);
|
||||
|
||||
Assert.assertEquals(3, xmlSlideShow.getSlides().size());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
File testFile = new File(fileLocation);
|
||||
if (testFile.exists()) {
|
||||
testFile.delete();
|
||||
}
|
||||
pph = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
### Relevant articles
|
||||
|
||||
- [Introduction to Apache Spark](http://www.baeldung.com/apache-spark)
|
||||
@@ -65,6 +65,24 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkCount>3</forkCount>
|
||||
<reuseForks>true</reuseForks>
|
||||
<excludes>
|
||||
<exclude>**/*IntegrationTest.java</exclude>
|
||||
<exclude>**/*LongRunningUnitTest.java</exclude>
|
||||
<exclude>**/*ManualTest.java</exclude>
|
||||
<exclude>**/JdbcTest.java</exclude>
|
||||
<exclude>**/*LiveTest.java</exclude>
|
||||
</excludes>
|
||||
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -107,4 +125,5 @@
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
+4
-4
@@ -40,14 +40,14 @@ public class CasSecuredAppApplication {
|
||||
@Primary
|
||||
public AuthenticationEntryPoint authenticationEntryPoint(ServiceProperties sP) {
|
||||
CasAuthenticationEntryPoint entryPoint = new CasAuthenticationEntryPoint();
|
||||
entryPoint.setLoginUrl("https://localhost:8443/cas/login");
|
||||
entryPoint.setLoginUrl("https://localhost:6443/cas/login");
|
||||
entryPoint.setServiceProperties(sP);
|
||||
return entryPoint;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TicketValidator ticketValidator() {
|
||||
return new Cas30ServiceTicketValidator("https://localhost:8443/cas");
|
||||
return new Cas30ServiceTicketValidator("https://localhost:6443/cas");
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -71,7 +71,7 @@ public class CasSecuredAppApplication {
|
||||
@Bean
|
||||
public LogoutFilter logoutFilter() {
|
||||
LogoutFilter logoutFilter = new LogoutFilter(
|
||||
"https://localhost:8443/cas/logout", securityContextLogoutHandler());
|
||||
"https://localhost:6443/cas/logout", securityContextLogoutHandler());
|
||||
logoutFilter.setFilterProcessesUrl("/logout/cas");
|
||||
return logoutFilter;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class CasSecuredAppApplication {
|
||||
@Bean
|
||||
public SingleSignOutFilter singleSignOutFilter() {
|
||||
SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter();
|
||||
singleSignOutFilter.setCasServerUrlPrefix("https://localhost:8443/cas");
|
||||
singleSignOutFilter.setCasServerUrlPrefix("https://localhost:6443/cas");
|
||||
singleSignOutFilter.setIgnoreInitConfiguration(true);
|
||||
return singleSignOutFilter;
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class CasSecuredAppApplicationTests {
|
||||
public class CasSecuredAppApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,9 +2,9 @@
|
||||
# CAS Server Context Configuration
|
||||
#
|
||||
server.context-path=/cas
|
||||
server.port=8443
|
||||
server.port=6443
|
||||
|
||||
server.ssl.key-store=file:/etc/cas/thekeystore
|
||||
server.ssl.key-store=classpath:/etc/cas/thekeystore
|
||||
server.ssl.key-store-password=changeit
|
||||
server.ssl.key-password=changeit
|
||||
# server.ssl.ciphers=
|
||||
@@ -40,6 +40,12 @@ spring.http.encoding.charset=UTF-8
|
||||
spring.http.encoding.enabled=true
|
||||
spring.http.encoding.force=true
|
||||
|
||||
##
|
||||
#CAS CONFIG LOCATION
|
||||
#
|
||||
cas.standalone.config=classpath:/etc/cas/config
|
||||
|
||||
|
||||
##
|
||||
# CAS Cloud Bus Configuration
|
||||
#
|
||||
@@ -82,6 +88,7 @@ spring.thymeleaf.mode=HTML
|
||||
# CAS Log4j Configuration
|
||||
#
|
||||
# logging.config=file:/etc/cas/log4j2.xml
|
||||
|
||||
server.context-parameters.isLog4jAutoInitializationDisabled=true
|
||||
|
||||
##
|
||||
@@ -102,11 +109,12 @@ cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ?
|
||||
cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
|
||||
cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect
|
||||
cas.authn.jdbc.query[0].user=root
|
||||
cas.authn.jdbc.query[0].password=
|
||||
cas.authn.jdbc.query[0].password=root
|
||||
cas.authn.jdbc.query[0].ddlAuto=none
|
||||
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
|
||||
#cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
|
||||
cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver
|
||||
cas.authn.jdbc.query[0].fieldPassword=password
|
||||
cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT
|
||||
cas.authn.jdbc.query[0].passwordEncoder.type=NONE
|
||||
|
||||
|
||||
##
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
cas.server.name: https://localhost:8443
|
||||
cas.server.prefix: https://localhost:8443/cas
|
||||
cas.server.name: https://localhost:6443
|
||||
cas.server.prefix: https://localhost:643/cas
|
||||
|
||||
cas.adminPagesSecurity.ip=127\.0\.0\.1
|
||||
|
||||
logging.config: file:/etc/cas/config/log4j2.xml
|
||||
|
||||
cas.serviceRegistry.initFromJson=true
|
||||
cas.serviceRegistry.config.location=classpath:/services
|
||||
|
||||
cas.authn.accept.users=
|
||||
cas.authn.accept.name=
|
||||
|
||||
|
||||
#CAS Database Authentication Property
|
||||
|
||||
# cas.authn.jdbc.query[0].healthQuery=
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
-- Dumping database structure for test
|
||||
CREATE DATABASE IF NOT EXISTS `test` /*!40100 DEFAULT CHARACTER SET latin1 */;
|
||||
USE `test`;
|
||||
|
||||
-- Dumping structure for table test.users
|
||||
CREATE TABLE IF NOT EXISTS `users` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email` varchar(50) DEFAULT NULL,
|
||||
`password` text DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
|
||||
|
||||
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
||||
INSERT INTO `users` (`id`, `email`, `password`) VALUES
|
||||
(1, '[email protected]', 'Mellon');
|
||||
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
||||
@@ -0,0 +1,2 @@
|
||||
info:
|
||||
description: CAS Configuration
|
||||
@@ -0,0 +1,7 @@
|
||||
cas.server.name: https://cas.example.org:8443
|
||||
cas.server.prefix: https://cas.example.org:8443/cas
|
||||
|
||||
cas.adminPagesSecurity.ip=127\.0\.0\.1
|
||||
|
||||
logging.config: file:/etc/cas/config/log4j2.xml
|
||||
# cas.serviceRegistry.config.location: classpath:/services
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- Specify the refresh internal in seconds. -->
|
||||
<Configuration monitorInterval="5" packages="org.apereo.cas.logging">
|
||||
<Properties>
|
||||
<!--
|
||||
Default log directory is the current directory but that can be overridden with -Dcas.log.dir=<logdir>
|
||||
Or you can change this property to a new default
|
||||
-->
|
||||
<Property name="cas.log.dir" >.</Property>
|
||||
<!-- To see more CAS specific logging, adjust this property to info or debug or run server with -Dcas.log.leve=debug -->
|
||||
<Property name="cas.log.level" >warn</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d %p [%c] - <%m>%n"/>
|
||||
</Console>
|
||||
<RollingFile name="file" fileName="${sys:cas.log.dir}/cas.log" append="true"
|
||||
filePattern="${sys:cas.log.dir}/cas-%d{yyyy-MM-dd-HH}-%i.log">
|
||||
<PatternLayout pattern="%d %p [%c] - <%m>%n"/>
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
<RollingFile name="auditlogfile" fileName="${sys:cas.log.dir}/cas_audit.log" append="true"
|
||||
filePattern="${sys:cas.log.dir}/cas_audit-%d{yyyy-MM-dd-HH}-%i.log">
|
||||
<PatternLayout pattern="%d %p [%c] - %m%n"/>
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
|
||||
<RollingFile name="perfFileAppender" fileName="${sys:cas.log.dir}/perfStats.log" append="true"
|
||||
filePattern="${sys:cas.log.dir}/perfStats-%d{yyyy-MM-dd-HH}-%i.log">
|
||||
<PatternLayout pattern="%m%n"/>
|
||||
<Policies>
|
||||
<OnStartupTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="10 MB"/>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
|
||||
<CasAppender name="casAudit">
|
||||
<AppenderRef ref="auditlogfile" />
|
||||
</CasAppender>
|
||||
<CasAppender name="casFile">
|
||||
<AppenderRef ref="file" />
|
||||
</CasAppender>
|
||||
<CasAppender name="casConsole">
|
||||
<AppenderRef ref="console" />
|
||||
</CasAppender>
|
||||
<CasAppender name="casPerf">
|
||||
<AppenderRef ref="perfFileAppender" />
|
||||
</CasAppender>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<!-- If adding a Logger with level set higher than warn, make category as selective as possible -->
|
||||
<!-- Loggers inherit appenders from Root Logger unless additivity is false -->
|
||||
<AsyncLogger name="org.apereo" level="${sys:cas.log.level}" includeLocation="true"/>
|
||||
<AsyncLogger name="org.apereo.services.persondir" level="${sys:cas.log.level}" includeLocation="true"/>
|
||||
<AsyncLogger name="org.apereo.cas.web.flow" level="info" includeLocation="true"/>
|
||||
<AsyncLogger name="org.apache" level="warn" />
|
||||
<AsyncLogger name="org.apache.http" level="error" />
|
||||
<AsyncLogger name="org.springframework" level="warn" />
|
||||
<AsyncLogger name="org.springframework.cloud.server" level="warn" />
|
||||
<AsyncLogger name="org.springframework.cloud.client" level="warn" />
|
||||
<AsyncLogger name="org.springframework.cloud.bus" level="warn" />
|
||||
<AsyncLogger name="org.springframework.aop" level="warn" />
|
||||
<AsyncLogger name="org.springframework.boot" level="warn" />
|
||||
<AsyncLogger name="org.springframework.boot.actuate.autoconfigure" level="warn" />
|
||||
<AsyncLogger name="org.springframework.webflow" level="warn" />
|
||||
<AsyncLogger name="org.springframework.session" level="warn" />
|
||||
<AsyncLogger name="org.springframework.amqp" level="error" />
|
||||
<AsyncLogger name="org.springframework.integration" level="warn" />
|
||||
<AsyncLogger name="org.springframework.messaging" level="warn" />
|
||||
<AsyncLogger name="org.springframework.web" level="warn" />
|
||||
<AsyncLogger name="org.springframework.orm.jpa" level="warn" />
|
||||
<AsyncLogger name="org.springframework.scheduling" level="warn" />
|
||||
<AsyncLogger name="org.springframework.context.annotation" level="error" />
|
||||
<AsyncLogger name="org.springframework.boot.devtools" level="error" />
|
||||
<AsyncLogger name="org.springframework.web.socket" level="warn" />
|
||||
<AsyncLogger name="org.thymeleaf" level="warn" />
|
||||
<AsyncLogger name="org.pac4j" level="warn" />
|
||||
<AsyncLogger name="org.opensaml" level="warn"/>
|
||||
<AsyncLogger name="net.sf.ehcache" level="warn" />
|
||||
<AsyncLogger name="com.couchbase" level="warn" includeLocation="true"/>
|
||||
<AsyncLogger name="com.ryantenney.metrics" level="warn" />
|
||||
<AsyncLogger name="net.jradius" level="warn" />
|
||||
<AsyncLogger name="org.openid4java" level="warn" />
|
||||
<AsyncLogger name="org.ldaptive" level="warn" />
|
||||
<AsyncLogger name="com.hazelcast" level="warn" />
|
||||
<AsyncLogger name="org.jasig.spring" level="warn" />
|
||||
|
||||
<!-- Log perf stats only to perfStats.log -->
|
||||
<AsyncLogger name="perfStatsLogger" level="info" additivity="false" includeLocation="true">
|
||||
<AppenderRef ref="casPerf"/>
|
||||
</AsyncLogger>
|
||||
|
||||
<!-- Log audit to all root appenders, and also to audit log (additivity is not false) -->
|
||||
<AsyncLogger name="org.apereo.inspektr.audit.support" level="info" includeLocation="true" >
|
||||
<AppenderRef ref="casAudit"/>
|
||||
</AsyncLogger>
|
||||
|
||||
<!-- All Loggers inherit appenders specified here, unless additivity="false" on the Logger -->
|
||||
<AsyncRoot level="warn">
|
||||
<AppenderRef ref="casFile"/>
|
||||
<!--
|
||||
For deployment to an application server running as service,
|
||||
delete the casConsole appender below
|
||||
-->
|
||||
<AppenderRef ref="casConsole"/>
|
||||
</AsyncRoot>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Binary file not shown.
Binary file not shown.
@@ -30,3 +30,5 @@
|
||||
- [The Difference Between map() and flatMap()](http://www.baeldung.com/java-difference-map-and-flatmap)
|
||||
- [Merging Streams in Java](http://www.baeldung.com/java-merge-streams)
|
||||
- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception)
|
||||
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
|
||||
- [Copy a File with Java](http://www.baeldung.com/java-copy-file)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
@Deprecated
|
||||
class ClassWithAnnotation {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
class ClassWithDeprecatedMethod {
|
||||
|
||||
@Deprecated
|
||||
static void deprecatedMethod() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
class ClassWithSafeVarargs<T> {
|
||||
|
||||
@SafeVarargs
|
||||
final void iterateOverVarargs(T... args) {
|
||||
for (T x : args) {
|
||||
// do stuff with x
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
class ClassWithSuppressWarnings {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
void useDeprecatedMethod() {
|
||||
ClassWithDeprecatedMethod.deprecatedMethod(); // no warning is generated here
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
@FunctionalInterface
|
||||
interface IntConsumer {
|
||||
|
||||
void accept(Integer number);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
import java.lang.annotation.Repeatable;
|
||||
|
||||
@Repeatable(Intervals.class)
|
||||
@interface Interval {
|
||||
int hour() default 1;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
public class IntervalUsage {
|
||||
|
||||
@Interval(hour = 17)
|
||||
@Interval(hour = 13)
|
||||
void doPeriodicCleanup() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
@interface Intervals {
|
||||
Interval[] value();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Inherited
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.LOCAL_VARIABLE, ElementType.FIELD})
|
||||
@interface MyAnnotation {
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user